/**
 * 
 */
package trigger;

/**
 * @author Philip
 *
 */
public abstract class DirectedResponseFlag extends TriggerFlagger {
	protected String receiver;

	public DirectedResponseFlag(Trigger flaggedTrigger) {
		super(flaggedTrigger);
		this.receiver = "";
	}
	
	public String response() {
		StringBuilder newResponse = new StringBuilder();
		
		for (int i = 0; i < linesInResponse() - 1; i++) {
			newResponse.append(command() + " " + receiver + " :" + flaggedTrigger.response(i) + "\n");
		}
		
		newResponse.append(command() + " " + receiver + " :" + flaggedTrigger.response(linesInResponse() - 1));
		
		return newResponse.toString();
	}
	
	public void updateVariables(String nickName, String sender, String receiver, String senderHostname, String input) {
		this.receiver = receiver;
		flaggedTrigger.updateVariables(nickName, sender, receiver, senderHostname, input);
	}
	
	public abstract String command();
}
